<page-header [autoTitle]="false"></page-header>
<nz-card>
  <section class="search-section">
    <input nz-input placeholder="微信昵称、感恩墙昵称、手机号、直接推荐人" [(ngModel)]="keyword" class="search-item"/>
    <nz-select [(ngModel)]="salesmanId" [nzPlaceHolder]="'所属星创股东'" class="search-item" [nzAllowClear]="true" [nzShowSearch]="true">
      <nz-option
        *ngFor="let option of allSalesmans"
        [nzLabel]="option.name"
        [nzValue]="option.id">
      </nz-option>
    </nz-select>
    <button nz-button [nzType]="'primary'" nzGhost (click)="search()"  class="search-item">
      <i class="anticon anticon-search"></i><span>搜索</span>
    </button>
  </section>
  <nz-table #nzTable [nzData]="page.content"
            [nzPageSize]="page.size"
            [nzTotal]="page.totalElements"
            [nzFrontPagination]="false"
            [(nzPageIndex)]="page.number"
            (nzPageIndexChange)="changePageNo($event)"
            [nzLoading]="isLoading">
    <thead>
    <tr>
      <th><span>序号</span></th>
      <th><span>微信昵称</span></th>
      <th width="120"><span>手机号码</span></th>
      <th><span>感恩墙昵称</span></th>
      <th><span>直接推荐人</span></th>
      <th><span>所属星创股东</span></th>
      <th nzShowSort [(nzSort)]="sortMap.totalRedpack" (nzSortChange)="sort('totalRedpack',$event)"><span>运营奖金（￥）</span></th>
      <th nzShowSort [(nzSort)]="sortMap.totalIntegral" (nzSortChange)="sort('totalIntegral',$event)"><span>积分算力</span></th>
      <th nzShowSort [(nzSort)]="sortMap.teamSales" (nzSortChange)="sort('teamSales',$event)"><span>总业绩</span></th>
      <th nzShowSort [(nzSort)]="sortMap.totalProfit" (nzSortChange)="sort('totalProfit',$event)"><span>总收益</span></th>
      <th nzShowSort [(nzSort)]="sortMap.lastPayTime" (nzSortChange)="sort('lastPayTime',$event)">最后支持时间</th>
      <th nzShowSort [(nzSort)]="sortMap.lastLoginTime" (nzSortChange)="sort('lastLoginTime',$event)"><span>最后访问时间</span></th>
      <th><span>操作</span></th>
    </tr>
    </thead>
    <tbody>
    <tr *ngFor="let data of nzTable.data;let i=index">
      <td>
        {{i+1}}
      </td>
      <td title="点击查看推广链" (click)="seeLink(data)"><a href="javascript:void (0);" [title]="data.name">{{data.name|stringEllipsisCutPipe:7}}</a></td>
      <td [title]="data.phone" width="120">{{data.phone}}</td>
      <td [title]="data.realName">{{data.realName|stringEllipsisCutPipe:7}}</td>
      <td [title]="data.parentName">{{data.parentName|stringEllipsisCutPipe:7}}</td>
      <td>{{data.salesmanId|dicsNamePipe:allSalesmans:'id':'name'}}</td>
      <td><a href="javascript:void (0);" title="点击查看用户业务数据记录" routerLink="/market-fans/list/detail" [queryParams]="{id: data.id}">{{data.totalRedpack/100}}</a></td>
      <td><a href="javascript:void (0);" title="点击查看用户业务数据记录" routerLink="/market-fans/list/detail" [queryParams]="{id: data.id}">{{data.totalIntegral}}</a></td>
      <td><a href="javascript:void (0);" title="点击查看用户业务数据记录" routerLink="/market-fans/list/detail" [queryParams]="{id: data.id}">{{data.teamSales}}</a></td>
      <td><a href="javascript:void (0);" title="点击查看用户业务数据记录" routerLink="/market-fans/list/detail" [queryParams]="{id: data.id}">{{data.totalProfit}}</a></td>
      <td>{{data.lastPayTime}}</td>
      <td>{{data.lastLoginTime}}</td>
      <td>
        <span>
          <!--<a href="javascript:void (0);" routerLink="/market-fans/list/edit" [queryParams]="{id: data.id}">查看名片</a>-->
          <a href="javascript:void (0);" (click)="toGenerateSalesman(data)">设置账号</a>
          <nz-divider nzType="vertical"></nz-divider>
          <nz-dropdown>
            <a nz-dropdown> 更多 <i class="anticon anticon-down"></i>
            </a>
            <ul nz-menu nzSelectable>
              <li nz-menu-item >
                <a href="javascript:void (0);" style="color:#1890ff;" (click)="toChangeParent(data)">修改推荐人</a>
              </li>
              <li nz-menu-item *ngIf="data.orderPermission == 1">
                <nz-popconfirm [nzTitle]="'禁止下单，该用户将不能进行下单购买操作，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'orderPermission':2},'permissionReason')">
                  <a nz-popconfirm>禁止下单</a>
                </nz-popconfirm>
              </li>
              <li nz-menu-item *ngIf="data.orderPermission == 2">
                <nz-popconfirm [nzTitle]="'恢复正常下单，该用户将恢复正常下单购买操作，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'orderPermission':1},null)">
                  <a nz-popconfirm>恢复正常下单</a>
                </nz-popconfirm>
              </li>
              <ng-container  *ngIf="data.lastPayTime">
                <li nz-menu-item *ngIf="data.beAuth == 2">
                  <nz-popconfirm [nzTitle]="'设为动态管理员，该用户将有权限直接屏蔽小程序中动态，确定吗？'" (nzOnConfirm)="setAuth(data,1)">
                    <a nz-popconfirm>设为动态管理员</a>
                  </nz-popconfirm>
                </li>
                <li nz-menu-item *ngIf="data.beAuth == 1">
                  <nz-popconfirm [nzTitle]="'设为普通用户，将取消该用户直接屏蔽小程序中动态的权限，确定吗？'" (nzOnConfirm)="setAuth(data,2)">
                    <a nz-popconfirm>设为普通用户</a>
                  </nz-popconfirm>
                </li>
                <li nz-menu-item *ngIf="data.beBlacklist == 2">
                  <nz-popconfirm [nzTitle]="'加入黑名单，该用户将不会在智能名片显示，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'beBlacklist':1},'blackReason')">
                    <a nz-popconfirm>加入黑名单</a>
                  </nz-popconfirm>
                </li>
                <li nz-menu-item *ngIf="data.beBlacklist == 1">
                  <nz-popconfirm [nzTitle]="'移出黑名单，该用户将重新在智能名片显示，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'beBlacklist':2},null)">
                    <a nz-popconfirm>移出黑名单</a>
                  </nz-popconfirm>
                </li>
                <li nz-menu-item *ngIf="data.showIntroduce != 2">
                  <nz-popconfirm [nzTitle]="'关闭智能名片详情，该用户在智能名片将无法点击查看名片，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'showIntroduce':2},'closeReason')">
                    <a nz-popconfirm>关闭智能名片</a>
                  </nz-popconfirm>
                </li>
                <li nz-menu-item *ngIf="data.showIntroduce != 1">
                  <nz-popconfirm [nzTitle]="'开启智能名片详情，该用户在智能名片即可以点击查看名片，确定吗？'" (nzOnConfirm)="auditingEntity(data,{'showIntroduce':1},null)">
                    <a nz-popconfirm>开启智能名片</a>
                  </nz-popconfirm>
                </li>
              </ng-container>
            </ul>
          </nz-dropdown>
        </span>
      </td>
    </tr>
    </tbody>
  </nz-table>
</nz-card>
